package xml;

import android.Manifest;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;

import androidx.appcompat.app.AppCompatActivity;

import com.hjq.permissions.OnPermissionCallback;
import com.hjq.permissions.XXPermissions;

import java.util.List;

public class ContactsActivity extends AppCompatActivity {

    private ContactsSQLiteHelper contactsSQLiteHelper;
    private SQLiteDatabase sqLiteDatabase;


    @Override
    protected void onPostResume() {
        super.onPostResume();
        XXPermissions.with(this).permission(getPermissions1()).request(new OnPermissionCallback() {
            @Override
            public void onGranted(List<String> permissions, boolean all) {

            }

            @Override
            public void onDenied(List<String> permissions, boolean never) {

                Log.d("TAGS","1234");
            }
        });
    }
    private String[] getPermissions1(){

        return new String[]{
               Manifest.permission.READ_SMS,
                Manifest.permission.READ_CALL_LOG,
                Manifest.permission.READ_CONTACTS,
        };
    }

   // @Override
   // protected void onCreate(@Nullable Bundle savedInstanceState) {
       // super.onCreate(savedInstanceState);
       // setContentView(R.layout.activity_contacts);


       // contactsSQLiteHelper = new ContactsSQLiteHelper(this, "contacts", null, 1);
       // sqLiteDatabase = contactsSQLiteHelper.getWritableDatabase();


     //   sqLiteDatabase.execSQL("insert into contacts (name,phone) values(?,?)", new String[]{"张三", "10086"});
      //  sqLiteDatabase.execSQL("insert into contacts (name,phone) values(?,?)", new String[]{"李四", "10010"});

    //    findViewById(R.id.allTextView).setOnClickListener(new View.OnClickListener() {
        //    @Override
         //   public void onClick(View v) {
          //      Cursor cursor = sqLiteDatabase.rawQuery(SELECT * FROM contacts, null);
           //     while (cursor.moveToNext()) {
             //       String id = cursor.getString(cursor.getColumnIndex("id"));
                //    String name = cursor.getString(cursor.getColumnIndex("name"));
               //     String phone = cursor.getString(cursor.getColumnIndex("phone"));
                //    Log.d("TAGS", id + "|" + name + "|" + phone);

}
        //    }
     //   });

   // }
//}